unit UCadastroOcorrencia;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, DBClient, Provider, DB, DBTables, Menus, StdCtrls,
  ComCtrls, DBCtrls, Buttons, Grids, DBGrids, ExtCtrls, Mask;

type
  TFCadastroOcorrencia = class(TFormCadastro)
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Table1: TTable;
    cdsCadastroPFO_CODIGO: TIntegerField;
    cdsCadastroPFO_CODIGO_OCORRENCIA: TStringField;
    cdsCadastroPFO_NIVEL: TStringField;
    cdsCadastroPFO_MENSAGEM: TStringField;
    cdsCadastroPFO_REGISTRO: TStringField;
    cdsCadastroUSUARIO_CADASTRO: TStringField;
    cdsCadastroUSUARIO_AUTERACAO: TStringField;
    cdsCadastroUSUARIO_EXCLUSAO: TStringField;
    cdsCadastroDATA_CADASTRO: TDateTimeField;
    cdsCadastroDATA_AUTERACAO: TDateTimeField;
    cdsCadastroDATA_EXCLUSAO: TDateTimeField;
    cdsCadastroCODIGOEMPRESA: TIntegerField;
    cdsCadastroEXCLUIDO: TStringField;
    Label1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    procedure BtnIncluirClick(Sender: TObject);
    procedure DBEdit5Exit(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCadastroOcorrencia: TFCadastroOcorrencia;

implementation

{$R *.dfm}

procedure TFCadastroOcorrencia.BtnIncluirClick(Sender: TObject);
begin
  inherited;

//  Table1.Refresh;

  if Table1.IsEmpty then
    cdsCadastro.FieldByName('PFO_CODIGO').AsInteger:=1
  else
  cdsCadastro.FieldByName('PFO_CODIGO').AsInteger:= Table1.RecordCount+1;

  DBEdit2.SetFocus;

end;

procedure TFCadastroOcorrencia.DBEdit5Exit(Sender: TObject);
begin
  inherited;
  BtnSalvar.SetFocus;
end;

procedure TFCadastroOcorrencia.BtnSalvarClick(Sender: TObject);
begin
  inherited;

  BtnIncluir.SetFocus;
  
end;

end.
